package com.ut.richpath.util;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

public class JsonUtil {

    public static String toJsonString(Object object){
        try {
            Gson gson = new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create();
            return gson.toJson(object);
        } catch (Exception e) {
            e.printStackTrace();
            return "json 序列化出错了！";
        }
    }

    public static String toJson(Object object){
        try {
            return new Gson().toJson(object);
        } catch (Exception e) {
            e.printStackTrace();
            return "json 序列化出错了！";
        }
    }



}
